﻿<%@ page contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" %>
<%@ include file="/commons/include.jsp" %>

<html>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
String toMobiles=request.getParameter("toMobiles");
String title =request.getParameter("title");
String content=request.getParameter("content");
String startDate=request.getParameter("startDate");
String loopType=request.getParameter("loopType");
%>
<head>
<base href="<%=basePath%>">
    <title>发送短信</title>  
    <link rel="stylesheet" type="text/css" media="all" href="<%=path%>/js/calendar/calendar-win2k-cold-1.css" title="win2k-cold-1" />
    <script type="text/javascript" src="<%=path%>/js/calendar/calendar.js"></script>
	<script type="text/javascript" src="<%=path%>/js/calendar/calendar-setup.js"></script>
	<script type="text/javascript" src="<%=path%>/js/calendar/calendar-zh1.js"></script>  
	<link href="<%=path%>/template/css.css" rel="stylesheet" type="text/css">
	<link href="<%=path%>/css/style.css" rel="stylesheet" type="text/css">
	
	</head>
	
<body class="iptform">
<table width='200' border='0' cellspacing='0' cellpadding='0'>
			<tr>
				<td width='90'><img src='images/loc-head.jpg' width='90' height='24'></td>
				<td valign='middle' nowrap background='images/loc-bg.jpg' class="title">短信群发</td>
				<td width='12'><img src='images/loc-tail.jpg' width='12' height='24'></td>
			</tr>
		</table><br>
<s:fielderror />
<s:form action="typedefineSave.action" name="inputform" enctype="multipart/form-data"  cssStyle="iptform" cssClass="iptform">
	<s:hidden name="id"/>
	<s:hidden name="mobilefilename"></s:hidden>
<table border="0" width="100%"  class="ipttable">
	<s:select onchange="tmplchange()" id="seltmpl" list="{'数据库','导入接受人'}" label="定时模板"></s:select>
	<s:textarea label="接收对象" id="toPersonsname" name="toPersonsname" rows="5" cols="70" onclick="openform()"></s:textarea>
	<s:hidden id="toPersons" name="toPersons"></s:hidden>
	<s:textarea name="toMobiles" id="toMobiles" label="接收号码" rows="5" cols="70" tooltip="接收号码以半角分号;隔开！"></s:textarea>
	<s:file name="mobilefile"></s:file>
	<s:textfield id="typeName" name='typeName' label='短信标题' size="50"/>
	<s:textarea label="短信内容"  name="content" rows="10" cols="70"></s:textarea>
	<s:textfield label="发送时间" id="smstime"  name="startDate" ></s:textfield>
	<s:textfield label="循环间隔" onclick="openunitwin()" id="loopType" name='loopType'/>
	<s:select name='status'  list="{'开启','关闭'}" value="status" label='状态'></s:select>
	<tr><td align="center">
			  <input class="submitbtn" type="button" onclick="document.all.inputform.submit()" value="提交" class="sbm">
			  <input class="resetbtn" type="reset"  value="重置">
			      </td></tr>
</table>
</s:form>
    <script type="text/javascript">
    setSelectValue('seltmpl','导入接受人');
    function setSelectValue(obj,val) { 
	  	if(!obj.selectedIndex)
	  	obj=document.getElementById(obj);
      var inputs = obj.options;
      for(var i=0;i<inputs.length;i++) {
      	//alert(inputs[i].value);
        if (inputs[i].value ==val) {
          inputs[i].selected = true;
          return;
        } 
      }
    }
    
    function tmplchange(){
    	//alert('tmplchange');
		window.location.href='<%=basePath%>jsp/TypeDefine/typedefineAdd.jsp';
		
	}
    function openunitwin(){
		var title = ""; 
		var url = '<%=basePath%>jsp/unitSel.jsp';
		var pageUrl="<%=basePath%>jsp/unitSel.jsp";
		var paraObj = new Object();
		paraObj.url=url;
		paraObj.title=title;
		var obj=document.getElementById('loopType');
		paraObj.input=obj;
		var sFeatures = 'help:no;status:1;dialogHeight:130px;dialogWidth:230px;center:1';
	    var rtnObj= window.showModalDialog(pageUrl,paraObj,sFeatures );
	    //alert('rtnObj='+rtnObj);
		if(rtnObj){
			var result=rtnObj.result;
			obj.value=result;
		}else{
    		
    	}
	}
    	function openform(){
    		var title = ""; 
		var url = '<%=basePath%>jsp/userSel.jsp';
		var pageUrl="<%=basePath%>jsp/userSel.jsp";
		var paraObj = new Object();
		paraObj.url=url;
		paraObj.title=title;
		var obj=document.getElementById('toPersons');
		var nmeobj=document.getElementById('toPersonsname');
		paraObj.input=obj;
		var sFeatures = 'help:no;status:1;dialogHeight:500px;dialogWidth:350px;center:1';
	    var rtnObj= window.showModalDialog(pageUrl,paraObj,sFeatures );
	    //alert('rtnObj='+rtnObj);
		if(rtnObj){
			var result=rtnObj.result;
			var rsname=rtnObj.resultname;
			obj.value=result;
			nmeobj.value=rsname;
		}else{
    		
    	}
    	//alert('openform');
    	}
    	
    	function openSelNormalInfo(){
    	var title = ""; 
		var url = 'selnormalsmsList.action';
		var pageUrl="selnormalsmsList.action";
		var paraObj = new Object();
		paraObj.url=url;
		paraObj.title=title;
		var obj=document.getElementById('content');
		paraObj.input=obj;
		var sFeatures = 'help:no;status:1;dialogHeight:500px;dialogWidth:350px;center:1';
	    var rtnObj= window.showModalDialog(pageUrl,paraObj,sFeatures );
	    //alert('rtnObj='+rtnObj);
		if(rtnObj){
			var result=rtnObj.result;
			obj.value=result;
		}else{
    		
    	}
    	}
    	
    	Calendar.setup(
		    {
		      inputField  : 'smstime',         // ID of the input field
		      ifFormat    : "%Y-%m-%d %H:%M:%S",    // the date format
		      onSelect   : onSelect,
		      showsTime : true
		    }
		  );
		 
function onSelect(calendar, date) {
    if (!IsDateBeforeToday(date)) {
    	var curEdt = document.getElementById(calendar.params.inputField.id);
      	curEdt.value = date;
      
    } else {
    	//alert();
    	window.status='所选日期不能小于今日!';
    }
	};

	 function IsDateBeforeToday(sDate) {
	   var ss = sDate.split('-'); 
	 var s = ss[1]+'-'+ss[2]+'-'+ss[0]; //形成月-日-年的格式,准备给Date.parse去解析
	 var d1 = new Date();
	 var d2 = Date.parse(s);
	 return d1 >= d2 ;
	 }
	 document.onclick=function(){
	 	if(parent){
	 		try{parent.clearMenu();}catch(e){}
	 	}
	 }
    </script>
</body>
</html>